package com.docking.heylo.web.controller;


import com.docking.heylo.service.ISysResourceService;
import com.docking.heylo.service.ISysRoleResourceService;
import com.docking.heylo.web.dto.SysRoleResourcesDto;
import com.docking.heylo.web.utils.ResultUtil;
import com.docking.heylo.web.vo.BaseVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;


/****
 *
 * 角色资源管理器
 *
 */
@RestController
@RequestMapping("/roleResources")
public class SysRoleResourcesController {

    @Autowired
    private ISysRoleResourceService roleResourcesService;

    @Autowired
    private ISysResourceService sysResourceService;


    /***
     * 更新角色资源
     *
     * @param
     * @return
     */
    @RequestMapping("/saveRoleResources")
    public BaseVo saveRoleResources(@RequestBody SysRoleResourcesDto roleResourcesDto){
        roleResourcesService.updateBatchRoleResources(roleResourcesDto);
        return ResultUtil.success("成功");
    }



    /***
     * 角色资源列表
     *
     * @return
     */
    @RequestMapping("/roleResourceList")
    private BaseVo roleResourceList(@RequestBody SysRoleResourcesDto roleResources){
        List<Map<String, Object>> holdResources = roleResourcesService.resourcesByRoleId(roleResources.getRoleId());
        return ResultUtil.success("成功",holdResources);
    }







}
